<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" > 

<html>
<head>
<base href="<%=basePath%>">
<title>疾病详情</title>
<link rel="stylesheet" href="./js/bootstrap-3.3.5-dist/css/bootstrap.css" type="text/css"/>
<link rel="stylesheet" href="./js/metisMenu/metisMenu.min.css">
<link rel="stylesheet" href="./css/sb-admin/sb-admin-2.css">
<link rel="stylesheet" href="./css/base.css">
<link rel="stylesheet" href="./css/illness.css">
<link rel="stylesheet" href="./js/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="./js/bootstrap-table/bootstrap-table.min.css">
<link rel="stylesheet" href="./js/bootstrap-multiselect/bootstrap-multiselect.css" type="text/css"/>
<link rel="stylesheet" href="./js/bootstrap-3.3.5-dist/css/bootstrap-datetimepicker.css">

<script type="text/javascript" src="./js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="./js/bootstrap-3.3.5-dist/js/bootstrap.js"></script>
<script type="text/javascript" src="./js/metisMenu/metisMenu.js"></script>
<script type="text/javascript" src="./js/common.js"></script>
<script src="./js/bootstrap-table/bootstrap-table-all.min.js"></script>
<script src="./js/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
<script src="./js/bootstrap-multiselect/bootstrap-multiselect.js"></script>
<script src="./js/bootstrap-jquery-plugin/jquery.bootstrap.js"></script>
<script src="./js/bootstrap-3.3.5-dist/js/bootstrap-datetimepicker.js"></script>
<script src="./js/bootstrap-3.3.5-dist/js/bootstrap-datetimepicker.zh-CN.js"></script>

</head>
<body>
	<jsp:include page="../template/head.jsp" />
	<jsp:include page="../template/leftnav.jsp" />
	<div id="page-wrapper">
		<div class="wrapper">
			<h1><a href="./jsp/illness/illness.jsp">疾病列表</a></h1><h3> <span> > </span> 疾病详情</h3>
		</div>
		<div class="bHead">
			<ul class="list-inline">	
				<li>
					<label>疾病名称：</label>
					<input class="form-control" style="display:-webkit-inline-box;width: inherit;" id="illName";/>
				</li>
			</ul>
		</div>	
		<div class="i-detail i-detail-info">
			<h3>基本信息</h3>
						<div class="list-inline" style="margin:5px">
				<label>多发性别：</label>
				<input class="form-control" style="width:85% !important; display:-webkit-inline-box;width: inherit;" id="specialCrowd"/>
				<div class="list-inline" style="display: none;">
					<select id="specialCrowdSel">
					    <option value="0" selected>男</option>
					    <option value="1" selected>女</option>
					    <option value="2" selected>全部</option>
					</select>
				</div>
			</div>
			<div class="list-inline" style="margin:5px">
				<label>疾病年龄：</label>
				<input class="form-control" style="width:85% !important; display:-webkit-inline-box;width: inherit;" id="age"/>
				<div class="list-inline" style="display: none;">
		        	<select id="ssdiseaseAgeSel" multiple="multiple">
					    <option value="0,6" selected>儿童(0~6)</option>
					    <option value="7,17" selected>少年(7~14)</option>
					    <option value="18,40" selected>青年(15~40)</option>
					    <option value="41,65" selected>中年(41~65)</option>
					    <option value="66,200" selected>老年(65以上)</option>
					</select>
				</div>
			</div>
			<div class="list-inline" style="margin:5px">
				<label>一级科目：</label>
				<input class="form-control" style="width:85% !important; display:-webkit-inline-box;width: inherit;" id="levelOneSubject"/>
			</div>
			<div class="list-inline" style="margin:5px">
				<label>二级科目：</label>
				<input class="form-control" style="width:85% !important; display:-webkit-inline-box;width: inherit;" id="levelTwoSubject"/>
			</div>
			<div class="list-inline" style="margin:5px;">
				<label>是否受伤：</label>
				<input class="form-control" style="width:85% !important; display:-webkit-inline-box;width: inherit;" id="isInjured"/>
				<div class="list-inline" style="display: none;">
					<select id="isInjuredSel">
					    <option value="1" selected>是</option>
					    <option value="0" selected>否</option>
					</select>
				</div>
			</div>

			<div class="list-inline" style="margin:5px">
				<label >发生时间：</label>
				<textarea class="form-control" style="width:85% !important; display:-webkit-inline-box;width: inherit;" id="duration" ></textarea>
			</div>
			<div class="list-inline" style="margin:5px">
				<label>辅助检查：</label>
				<textarea class="form-control" style="width:85% !important; display:-webkit-inline-box;width: inherit;" id="examNames" ></textarea>
			</div>
			<div class="list-inline" style="margin:5px">
				<label>病情病因：</label>
				<textarea class="form-control" style="width:85% !important; display:-webkit-inline-box;width: inherit;" id="pathogen" ></textarea>
			</div>
			<div class="list-inline" style="margin:5px">
				<label>诊疗方案：</label>
				<textarea class="form-control" style="width:85% !important; display:-webkit-inline-box;width: inherit;" id="scheme" ></textarea>
			</div>
			<div class="list-inline" style="margin:5px">
				<label>疾病用药：</label>
				<textarea class="form-control" style="width:85% !important; display:-webkit-inline-box;width: inherit;" id="medicines" ></textarea>
			</div>

		</div>
		
		<div class="panel bs-panel-primary" style="height: auto !important" >
			<div class="panel-heading">症状名称:
				<span class="btn detail—btn" onclick="addSymptomDiv()">添加</span>
			</div>
			<div class="list-inline" >
				<div style="margin:5px 5px 5px 15px;">
					<!-- <label>其它病症：</label> -->
				</div>
				<div id="ii"></div>
			</div>
		</div>
		
		<div class="panel bs-panel-primary" style="height: auto !important" >
			<div class="panel-heading">部位名称:
				<span class="btn detail—btn" onclick="addpartsDiv()">添加</span>
			</div>
			<div class="list-inline" >
				<div id="pp"></div>
			</div>
		</div>
		
<!-- 		<div style="text-align: center;padding: 40px 0;">
			<button onclick="addIll()" class="btn btn-primary">提交</button>
			<a href="./jsp/illness/illness.jsp" class="btn btn-primary">取消</a>
		</div> -->
		
		
		
		<div id="eidtwrap" style="display:none">
		  <form id="editform" role="form" class="form-horizontal">
			<img alt="" src="" id="imgurls">
		</div>
		
</body>
<script type="text/javascript">

	function showimg(url){
	   	$("#eidtwrap").show();
	   	$("#imgurls").attr("src", "../img/"+url); 
		$("#eidtwrap").dialog({
	         	title   : "图片预览",
	        	'class' :  "mydialog",
	        	onClose : function() { 
	         		 $(this).dialog("close");
	          	}, 
	          	buttons : [{
	             text : "关闭",
	             'class' : "btn btn-default",
	             click : function() {
	                	 $(this).dialog("close");
	             	}
	         }]
	     });
	}


	function showPartsDiv(data){
		var html = '<div style="margin:5px 5px 5px 15px;">'+
			'<span style="color: #37bd9c;" class="glyphicon glyphicon-plus icon-plus" aria-hidden="true" ></span>'+
			'<input class="form-control" style="display:-webkit-inline-box;width: inherit;margin:3px;" id="p'+data.id+'" '+'/>'+
			'</div>';
		var div =document.createElement("div");
        div.innerHTML=html;
   		document.getElementById("pp").appendChild(div);
	}
	
	function showSymptomDiv(data){
		var html = '<div style="margin:5px 5px 5px 15px;">'+
			'<span style="color: #37bd9c;" class="glyphicon glyphicon-plus icon-plus" aria-hidden="true" ></span>'+
			'<lable>症状名：</lable>'+
			'<input class="form-control" style="display:-webkit-inline-box;width: inherit;" id="symptom'+data.id+'" '+'/>'+
			'<lable>程度：</lable>'+
			'<input class="form-control" style="display:-webkit-inline-box;width: inherit;width: 13%;margin:3px;" id="degree'+data.id+'" '+'/>'+
			'<lable>性质：</lable>'+
			'<input class="form-control" style="display:-webkit-inline-box;width: inherit;width: 13%;margin:3px;" id="nature'+data.id+'" '+'/>'+
			'<lable>次数：</lable>'+
			'<input class="form-control" style="display:-webkit-inline-box;width: inherit;width: 13%;margin:3px;" id="times'+data.id+'" '+'/>'+
			'<lable>用药：</lable>'+
			'<input class="form-control" style="display:-webkit-inline-box;width: inherit;width: 13%;margin:3px;" id="medicine'+data.id+'" '+'/>'+
			'<br>'+
			'<span style="color: #37bd9c;opacity:0;" class="glyphicon glyphicon-plus icon-plus" aria-hidden="true" ></span>'+
			'<lable>值下限：</lable>'+
			'<input class="form-control" style="display:-webkit-inline-box;width: inherit;width: 13%;margin:3px;" id="sdown'+data.id+'" '+'/>'+
			'<lable>值上行：</lable>'+
			'<input class="form-control" style="display:-webkit-inline-box;width: inherit;width: 13%;margin:3px;" id="sup'+data.id+'" '+'/>'+
			'<lable>范围：</lable>'+
			'<input class="form-control" style="display:-webkit-inline-box;width: inherit;" id="type'+data.id+'" />'+
			'<lable id="imgurltext'+data.id+'">图片：</lable>'+
			'<input class="form-control" style="display:-webkit-inline-box;width: inherit; width: 24%;"  id="imgurl'+data.id+'" />'+
			'<span class="btn detail—btn" onclick="showimg(\''+data.imgurl+'\')" style="margin-left:3px;" id="imgurlBT'+data.id+'">预览</span>'+
			'</div>';
		var div =document.createElement("div");
        div.innerHTML=html;
   		document.getElementById("ii").appendChild(div);
	}
	
	var illName = $.getUrlParam("illName");
	$("#illName").val(illName);
	$("#illName").attr({readonly:'true'});
	
	$(function (){
	
	 	$('#isInjuredSel').multiselect({
		 	includeSelectAllOption: true,
		 	buttonWidth: '150px'
		 });
		 
	 	 $('#ssdiseaseAgeSel').multiselect({
		 	includeSelectAllOption: true,
		 	selectAllText: "全部年龄",
		 	allSelectedText:"全选",
		 	nonSelectedText:"无",
		 	buttonWidth: '150px'
		 });
		 
	 	 $('#specialCrowdSel').multiselect({
		 	includeSelectAllOption: true,
		 	buttonWidth: '150px'
		 });
	
		$.ajax({
           url: "./adminIllness/getIllnessDetail.spring",
           data: {
               illness: $.getUrlParam("illName")
           },
           type: "GET",
           dataType: 'json',
           cache: false,
           success: function (ret) {
              $("#levelOneSubject").val(ret.levelOneSubject);
              $("#levelOneSubject").attr({readonly:'true'});
              $("#levelTwoSubject").val(ret.levelTwoSubject);
              $("#levelTwoSubject").attr({readonly:'true'});
              $("#duration").val(ret.duration);
              $("#duration").attr({readonly:'true'});
              $("#examNames").val(ret.assistantExam);
              $("#examNames").attr({readonly:'true'});
              $("#scheme").val(ret.scheme);
              $("#scheme").attr({readonly:'true'});
              $("#pathogen").val(ret.pathogen);
              $("#pathogen").attr({readonly:'true'});
              $("#medicines").val(ret.medicine);
              $("#medicines").attr({readonly:'true'});
			  if(ret.isInjured==1){
			  	$("#isInjured").val("是");
			  }else{
			  	$("#isInjured").val("否");
			  }
              $("#isInjured").attr({readonly:'true'});
              
              if(ret.specialCrowd==0){
              	$("#specialCrowd").val("男");
              }else if(ret.specialCrowd==1){
              	$("#specialCrowd").val("女");
              }else{
              	$("#specialCrowd").val("全部");
              }
              $("#specialCrowd").attr({readonly:'true'});
              
              if(ret.diseaseStartTime==0 && ret.diseaseEndTime==200){
              	$("#age").val("全年龄段");
              }else{
              	$("#age").val(ret.diseaseStartTime+"~"+ret.diseaseEndTime+"岁");
              }
              $("#age").val(ageFormatter(ret));
              $("#age").attr({readonly:'true'});
              
              for(var i=0;i<ret.partss.length;i++){
              	showPartsDiv(ret.partss[i]);
              	$("#p"+ret.partss[i].id+"").val(ret.partss[i].part);
              }
              
              for(var i=0;i<ret.symptoms.length;i++){

              		showSymptomDiv(ret.symptoms[i]);
              		$("#symptom"+ret.symptoms[i].id+"").val(ret.symptoms[i].symptom);
              		$("#degree"+ret.symptoms[i].id+"").val(ret.symptoms[i].degree);
              		$("#nature"+ret.symptoms[i].id+"").val(ret.symptoms[i].nature);
              		$("#times"+ret.symptoms[i].id+"").val(ret.symptoms[i].times);
              		$("#medicine"+ret.symptoms[i].id+"").val(ret.symptoms[i].medicine);
              		if(ret.symptoms[i].type==1){
              			$("#type"+ret.symptoms[i].id+"").val("是");
              		}else{
              			$("#type"+ret.symptoms[i].id+"").val("否");
              		}
              		
              		$("#sdown"+ret.symptoms[i].id+"").val(ret.symptoms[i].sdown);
              		$("#sup"+ret.symptoms[i].id+"").val(ret.symptoms[i].sup);
              		var imgu = ret.symptoms[i].imgurl;
              		if(imgu=='' || imgu==null){
              			$("#imgurl"+ret.symptoms[i].id+"").hide(); 
						$("#imgurlBT"+ret.symptoms[i].id+"").hide();  
						$("#imgurltext"+ret.symptoms[i].id+"").hide();
              		}else{
          		         $("#imgurl"+ret.symptoms[i].id+"").val(imgu);
              		}
              }
           }
       });
	});
	
	function ageFormatter(row){
		var length = row.ages.length;
		if(length==0){
			return '';
		}
		if(length==5){
			return '全年龄段';
		}
		var ages = '';
		for(var i=0;i<length;i++){
			var s = row.ages[i].ageOption;
			var ss;
			if(s==1){
				ss = '0~6岁';
			}else if(s==2){
				ss = '7~14岁';
			}else if(s==3){
				ss = '15~40岁';
			}else if(s==4){
				ss = '41~65岁';
			}else if(s==5){
				ss = '65岁以上';
			}
			ages =ages + ',' + ss  ;
		}
		var t = ages.substring(1,ages.length)
		return t;
	}
</script>
</html>
